//mlcai add this IO interface to write message to
//client destination eg. file, console, network...
//mlcai 2011-03-08

#ifndef GIOSTREAM_H_INCLUDED
#define GIOSTREAM_H_INCLUDED

#include <cstdio>
#include <cstdarg>

class GIOStream
{
public:
    virtual ~GIOStream();

    virtual GIOStream& write(const char* buf, size_t size) = 0;
    virtual GIOStream& read(const char* buf, size_t size) = 0;

    virtual int print(const char* formart, ...);
    virtual int scan(const char* formart, ...);

    virtual bool getCharactor(char& ch) = 0;
    virtual bool ungetCharactor(const char& ch) = 0;

protected:
    GIOStream();
};


//factory use to create concrete GIOStream
class GIOStreamFactory
{
public:
    virtual ~GIOStreamFactory();

    static GIOStreamFactory* instance();

    virtual GIOStream* createIO() = 0;

protected:
    GIOStreamFactory();
    static GIOStreamFactory* _ioFactory;
};


#endif // GIOSTREAM_H_INCLUDED
